﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using ChapterX.Common;
using ChapterX.Data.ChaptersDSTableAdapters;

namespace ChapterX.Modules
{
    public partial class BookChapterListModule : ChapterX.Model.DataListModuleBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindChapterList();
            }
        }


        protected void BindChapterList()
        {
            int bookId;
            if (Utils.HasValue(Request.QueryString[QueryKeys.BOOK_ID]) &&
                Int32.TryParse(Utils.GetValue(Request.QueryString[QueryKeys.BOOK_ID]), out bookId))
            {
                this.hf_bookId.Value = bookId.ToString();

                try
                {
                    ChaptersTableAdapter adapter = new ChaptersTableAdapter();
                    this.rp_ChapterList.DataSource = adapter.GetChaptersByBookId(bookId);
                    this.rp_ChapterList.DataBind();
                }
                catch (Exception ex)
                {
                    SetErrorMessage("数据绑定失败");
                    Logger.Log(ex);
                }
            }
        }
    }
}